package com.edu.study.base.stuCourseExercisesDetail.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.edu.study.base.stuCourseExercisesDetail.domain.StuCourseExercisesDetail;
import com.edu.study.base.stuCourseExercisesDetail.service.IStuCourseExercisesDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 课后练习完成情况Controller
 * 
 * @author zw
 * @date 2021-08-30
 */
@RestController
@RequestMapping("/stuCourseExercisesDetail/stuCourseExercisesDetail")
public class StuCourseExercisesDetailController extends BaseController
{
    @Autowired
    private IStuCourseExercisesDetailService stuCourseExercisesDetailService;

    /**
     * 查询课后练习完成情况列表
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesDetail:stuCourseExercisesDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(StuCourseExercisesDetail stuCourseExercisesDetail)
    {
        startPage();
        List<StuCourseExercisesDetail> list = stuCourseExercisesDetailService.selectStuCourseExercisesDetailList(stuCourseExercisesDetail);
        return getDataTable(list);
    }

    /**
     * 导出课后练习完成情况列表
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesDetail:stuCourseExercisesDetail:export')")
    @Log(title = "课后练习完成情况", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StuCourseExercisesDetail stuCourseExercisesDetail)
    {
        List<StuCourseExercisesDetail> list = stuCourseExercisesDetailService.selectStuCourseExercisesDetailList(stuCourseExercisesDetail);
        ExcelUtil<StuCourseExercisesDetail> util = new ExcelUtil<StuCourseExercisesDetail>(StuCourseExercisesDetail.class);
        return util.exportExcel(list, "stuCourseExercisesDetail");
    }

    /**
     * 获取课后练习完成情况详细信息
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesDetail:stuCourseExercisesDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(stuCourseExercisesDetailService.selectStuCourseExercisesDetailById(id));
    }

    /**
     * 新增课后练习完成情况
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesDetail:stuCourseExercisesDetail:add')")
    @Log(title = "课后练习完成情况", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StuCourseExercisesDetail stuCourseExercisesDetail)
    {
        return toAjax(stuCourseExercisesDetailService.insertStuCourseExercisesDetail(stuCourseExercisesDetail));
    }

    /**
     * 修改课后练习完成情况
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesDetail:stuCourseExercisesDetail:edit')")
    @Log(title = "课后练习完成情况", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StuCourseExercisesDetail stuCourseExercisesDetail)
    {
        return toAjax(stuCourseExercisesDetailService.updateStuCourseExercisesDetail(stuCourseExercisesDetail));
    }

    /**
     * 删除课后练习完成情况
     */
    @PreAuthorize("@ss.hasPermi('stuCourseExercisesDetail:stuCourseExercisesDetail:remove')")
    @Log(title = "课后练习完成情况", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(stuCourseExercisesDetailService.deleteStuCourseExercisesDetailByIds(ids));
    }
}
